<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/my_log_register.css">
    <link rel="stylesheet" href="css/style.css">

    <style>
        body {
            background: url(../images/timg6.jpg) no-repeat fixed;
            background-size: cover;
            width: 100%;
        }
    </style>

</head>

<body>
    <!-- 注册框 -->
    <div id="" class="container shadow p-3 mb-5 rounded" style="font-family: cursive;">
        <div id="title">
            <h1 style="text-align: center; padding-top: 0.5rem;">注 册</h1>
        </div>
        <!-- 表单 -->
        <form id="registerForm" action="/registerDone" method="POST">
            <!-- 文本框 -->
            <div id="body_middle">

                <div class="row">
                    <div class="col">
                        <center>
                            <img src="images/用户名.png" alt=""
                                style="width: 25px; height: 25px; position: absolute; left: 6rem; top: 0.5rem;">
                            <input type="text" class="form-control" id="username" name="username"
                                placeholder="用户名/手机号/邮箱" style="width: 50%; text-align: center;">
                            <!-- <small id="comment" class="form-text text-muted">{{msg}}</small> -->
                        </center>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <center>
                            <img src="images/锁头.png" alt=""
                                style="width: 25px; height: 25px; position: absolute; left: 6rem; top: 0.5rem;">
                            <input type="password" class="form-control" id="password" name="password"
                                placeholder="请输入密码" style="width: 50%; text-align: center">
                        </center>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <center>
                            <center>
                                <img src="images/锁头.png" alt=""
                                    style="width: 25px; height: 25px; position: absolute; left: 6rem; top: 0.5rem;">
                                <input type="password" class="form-control" id="confirmpassword" name="confirmpassword"
                                    placeholder="请确认密码" style="width: 50%; text-align: center">
                            </center>
                    </div>
                </div>
            </div>
            <br>
            <!--换行 -->
            <!-- <hr>底线 -->
            <!-- 按钮组件 -->
            <div style="text-align: center;">
                <button type="button" class="btn btn-outline-success" style="width: 5.5rem;"
                    onclick="jump()">注册</button>
                &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                <a href="#" onclick="login()">
                    <button type="button" class="btn btn-outline-success" style="width: 5.5rem;"
                        name="reset">取消</button>
                </a>
                <!--onclick="jumpOut()"-->
            </div>
        </form>

        <!-- 注册提示框  -->
        <div class="col">
            <div class="alert alert-danger alert-dismissible fade show invisible" role="alert">
                <strong class="alert-dan">提示：</strong><label for="" id="msgId">敦煌</label>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        </div>

    </div>


    


    <!-- 壁纸切换 -->
    <div id="div_NetMonitor">
        <div id="div_netMon1" onclick="checkNet1()"><img src="../images/timg2.jpg"></div>
        <div id="div_netMon2" onclick="checkNet2()"><img src="../images/timg3.jpg"></div>
        <div id="div_netMon3" onclick="checkNet3()"><img src="../images/timg4.jpg"></div>
        <div id="div_netMon4" onclick="checkNet4()"><img src="../images/timg5.jpg"></div>
        <div id="div_netMon5">Wallpaper</div>

        <!-- xmlns="http://www.w3.org/2000/svg"  -->
        <div id="div_netMon6" title="Wallpaper" onclick="checkWallpaper()">
            <svg t="1590074189701" class="icon-suspension" id="icon-sus1" viewBox="0 0 1000 1000" version="1.1"
                p-id="1773" width="200" height="200">
                <path
                    d="M500 0c-276.1563 0-500 223.8438-500 500s223.8438 500 500 500 500-223.8438 500-500-223.8438-500-500-500zM500 906.25c-224.375 0-406.25-181.875-406.25-406.25s181.875-406.25 406.25-406.25 406.25 181.875 406.25 406.25-181.875 406.25-406.25 406.25zM794.1875 455.8125l-250-250c-24.4063-24.4063-63.9688-24.4063-88.375 0s-24.4063 63.9688 0 88.375l143.3125 143.3125h-349.125c-34.5313 0-62.5 27.9688-62.5 62.5s27.9688 62.5 62.5 62.5h349.125l-143.3125 143.3125c-24.4063 24.4063-24.4063 63.9688 0 88.4063 12.2188 12.1875 28.1875 18.3125 44.1875 18.3125s32-6.0938 44.1875-18.3125l250-250c24.4063-24.4063 24.4063-63.9688 0-88.375z"
                    fill="#1571fa" p-id="1774"></path>
            </svg>
            <svg t="1590076234376" class="icon-suspension" id="icon-sus2" viewBox="0 0 1000 1000" version="1.1"
                p-id="5476" width="200" height="200">
                <path
                    d="M500 0c276.1563 0 500 223.8438 500 500s-223.8438 500-500 500-500-223.8438-500-500 223.8438-500 500-500zM500 906.25c224.375 0 406.25-181.875 406.25-406.25s-181.875-406.25-406.25-406.25-406.25 181.875-406.25 406.25 181.875 406.25 406.25 406.25zM205.8125 455.8125l250-250c24.4063-24.4063 63.9688-24.4063 88.375 0s24.4063 63.9688 0 88.375l-143.3125 143.3125h349.125c34.5313 0 62.5 27.9688 62.5 62.5s-27.9688 62.5-62.5 62.5h-349.125l143.3125 143.3125c24.4063 24.4063 24.4063 63.9688 0 88.4063-12.2188 12.1875-28.1875 18.3125-44.1875 18.3125s-32-6.0938-44.1875-18.3125l-250-250c-24.4063-24.4063-24.4063-63.9688 0-88.375z"
                    p-id="5477" fill="#1571fa"></path>
            </svg>
        </div>
    </div>

    <script src="js/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/register_btn.js"></script>
    <script src="js/register_input_focus.js"></script>
    <script src="js/FormValidator.js"></script>

    <script>
        function login() {
            window.location.href = '/login';
        }
        function jump() {
            // 获取表单数据
            let uid = $('#username').val();
            let pwd = $('#password').val();
            let confirmpwd = $('#confirmpassword').val();

            // 判断用户名、密码是否为空，为空则提示；不为空则向服务器提交
            if (uid.length > 0 && pwd.length > 0 && pwd === confirmpwd) {
                axios({
                    method: 'post',
                    url: '/registerDone',
                    data: $('#registerForm').serialize(),
                }).then(function (res) {
                    // axios工具下，服务器真正返回的数据在返回对象的data中
                    res = res.data;
                    if (res.code === 200) {
                        window.location.href = '/login';
                    } else {
                        alert_fn(res.msg);
                        console.log(res.msg);
                    }
                }).catch((err) => {
                    alert_fn(err);
                    console.log(err);
                });
            } else {
                alert_fn('用户名、密码不能为空，且两次密码一致');
            }
        }

        // 包装了显示（以及自动隐藏）消息警告的动作
        function alert_fn(msg) {
            $('#msgId').text(msg);
            $('.alert').removeClass('invisible');
            setTimeout(() => {
                $('.alert').addClass('invisible');
            }, 3000);
        }
    </script>
</body>

</html>